<?php

namespace App\Http\Controllers\Configuration;

use App\Http\Controllers\Controller;
use App\Utils\ApiResponse;
use App\Models\WPTerm;
use LaraPress\Config\LaraPressCms;

class Cms extends Controller
{
    /**
     * @group 配置
     * @subgroup CMS设置
     *
     * 获取WordPress CMS的基础配置信息，包括首页布局样式和显示分类。
     *
     * @response 200 {
     *   "code": 200,
     *   "message": "操作成功",
     *   "data": {
     *     "home_layout_style": "grid",
     *     "home_show_category": [
     *       {
     *         "term_id": 1,
     *         "name": "技术",
     *         "slug": "tech",
     *         "description": "技术相关内容"
     *       }
     *     ]
     *   }
     * }
     *
     * @response 500 {
     *   "code": 500,
     *   "message": "获取配置失败: 错误信息",
     *   "data": null
     * }
     */
    public function index()
    {
        $data = [
            'home_layout_style' => LaraPressCms::get_option('home_layout_style'),
            'home_show_category' => WPTerm::get_terms_by_id(LaraPressCms::get_option('home_show_category')),
        ];
        return ApiResponse::success($data);
    }
}
